package com.sxxm.qxgl.controller;


import com.sxxm.qxgl.dto.cx;
import com.sxxm.qxgl.dto.yh_js;
import com.sxxm.qxgl.entity.SysRole;
import com.sxxm.qxgl.entity.SysUser;
import com.sxxm.qxgl.service.SysRoleService;
import com.sxxm.qxgl.utils.TokenUtils;
import com.sxxm.qxgl.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.security.RolesAllowed;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 角色表 前端控制器
 * </p>
 *
 * @author qjw
 * @since 2021-09-14
 */
@RestController
@Api(value = "角色", tags = "角色")
@RequestMapping("/sys-role")
public class SysRoleController {
    SysRoleService sysRoleService;
    public SysRoleController(SysRoleService sysRoleService){
        this.sysRoleService=sysRoleService;
    }
    @ApiOperation("查询")
    @PostMapping("/cx")
    public Result cx(@RequestBody cx sysRole){
        return sysRoleService.cx(sysRole.getId(),sysRole.getName(),sysRole.getPage(),sysRole.getNumber());
    }

    @ApiOperation("修改")
    @PostMapping("/ModifyThe")
    public Result ModifyThe(@RequestBody SysRole sysUser){
        return sysRoleService.ModifyThe(sysUser);
    }
    @ApiOperation("添加")
    @PostMapping("/Addition")
    public Result Addition(@RequestBody SysRole sysUser){
        return sysRoleService.Addition(sysUser);
    }
    @ApiOperation("删除")
    @PostMapping("/Delete")
    public Result Delete(@RequestBody SysRole sysUser){
        return sysRoleService.Delete(sysUser.getId());
    }

    @ApiOperation("状态")
    @PostMapping("/zt")
    public Result zt(@RequestBody SysRole sysUser){
        return sysRoleService.zt(sysUser.getId());
    }
    @ApiOperation("通过角色查询用户")
    @PostMapping("/cxyh")
    public Result cxyh(@RequestBody yh_js yh){
        return sysRoleService.xcyh(yh.getId(),yh.getUserType());
    }
    @ApiOperation(value = "修改角色信息", notes = "修改角色信息")
    @PostMapping("/getMenu")
    public Result getMenu(HttpServletRequest request) {
        String userID = TokenUtils.getUserID(request);
        return sysRoleService.getMenu(userID);
    }
//    @ApiOperation("通过角色添加用户")
//    @GetMapping("/tjyh")
//    public Result tjyh(List<Integer> id){
//        return sysRoleService.tjyh(id);
//    }
}

